# 十佳歌手
# 评分列表
score_li = []
# 总分
total_score = 0
for i in range (1,11):
    score = float(input(f"请地{i}位评委输入评分:\n"))
    score_li.append(score)
score_li.sort()
print(f"去掉最低分:{score_li[0]}")
print(f"去掉最低分:{score_li[len(score_li)-1]}")
#去掉最低分
score_li.remove (score_li[0])
# 去掉最高分
score_li.pop()
for j in score_li:
    total_score += j
print(f"选手最终得分为:{toatal_score/(len(score_li))}")

# 神奇的魔法方阵
n = 5
# 5*5二维列表
magic_square =[ [0 for x in range(n)]
for y in range(n)]
i = n / 2
j = n - 1
num = 1
while num <=(n * n):
    if i == -1 and j == n:
        j = n - 2
        i = 0
    else:
        if j == n:
            j = 0
        if i < 0:
            i = n - 1
    if magic_square[int(i)][int(j)]:
        j = j - 2
        i = i + 1
        continue
    else:
        magic_square[int(i)][int(j)] = num
        num = num + 1
    j = j + 1
    i = i - 1
for i in range(0,n):
    for j in range(0,n):
        print('%2d' % (magic_square[i][j]),end = '')
        if j == n - 1:
            print()

# 青春有你
play_info = {}
li = []
print('输入quit表示选手成绩录入完毕')
while True:
    name = input("请输入选手名称: \n")
    if name == 'quit':
        break
    score = float(input("请输入选手票数: \n"))
    play_info[name] = score
items = player_info.items()
for j in items:
    li.append([j[1],j[0]])
# 转换为list类型，进行排序
li.sort()
# 获取选手索引
count = len(li) - 1
# 输出排名
for i in range (1,len(li) + 1):
    print(f"第{i}名:{li[count][1]},成绩为{li[count][0]}分")
    count -= 1

# 手机通讯录
person_info = []
print("=" * 20)
print('欢迎使用通讯录:')
print("1.添加联系人")
print("2.查看通讯录")
print("3.删除联系人")
print("4.修改联系人信息")
print("5.查出联系人")
print("6.退出")
print("=" * 20)
while True:
    per_dict = {}
    fun_num = input('请输入功能序号:')
    if fun_num == '1':
        per_name = input('请输入联系人的姓名:')
        phone_num = input('请输入联系人的手机号:')
        per_email = input('请输入联系人的邮箱:')
        per_address = input('请输入联系人的地址:')
# 判断输入的是否为空
    if per_name.strip() == '':
        print('请输入正确的信息')
        continue
    else:
        per_dict.update({'姓名':per_name,
                         '手机号':phone_num,
                         '电子邮箱':per_email
                         '联系地址':per_address})
        person_info.append(per_dict) #保存到列表
        print('保存成功')                 
elif fun_num == '2':
    if len(person_info) == 0:     
        print('通讯录无信息')
    for i in person_info:
        for title,info in i.item():
            print(title + ':' + info)
elif fun_num == '3': #删除
    if len(person_info) != 0:
        del_name = input ('请输入要删除的联系人姓名') 
        for i in person_info:
            if del_name in i.values():
            person_info.remove(i)
            print(person_info)
            print('删除成功')
        else:
            print('该联系人不在通讯录中')
        else:
            print ('通讯录无信息')
elif fun_num == '4': #修改
    if len(person_info) != 0:
        modi_info = input('请输入要修改人联系人姓名:')
        for i in person_info:
            if modi_info in i.value():
                #获取所在元祖列表中的索引位置
                index_num = person_info.index(i)
                dict_cur_perinfo = person_info[index_num]
                for title,info in dict_cur_perinfo.items():
                    print(title + ':'+info)
                modi_name = input('请输入新的姓名:')
                modi_phone = input('请输入新的手机号:')
                modi_email = input('请输入新的邮箱:')
                modi_address = input('请输入新的地址:')
                dict_cur_perinfo.update(姓名=modi_name)
                dict_cur_perinfo.update(手机号=modi_phone)
                dict_cur_perinfo.update(电子邮箱=modi_email)
                dict_cur_perinfo.update(联系地址=modi_address)
                print(person_info)
    else:
        print('通讯录无信息')
elif fun_num =='5': #查找
    if len(person_info) != 0:
        query_name = input('请输入要查找的联系人姓名:')
        for i in person_info:
            if query_name in i.values():
                index_num = person_info.index(i)
                for title, info in person_info[index_num].items():
                    break
        else:
            print('该联系人不在通讯录中')
    else:
        print('通讯录无信息')
elif fun_num == '6':   #退出
        break


























